# 解构元组
a1, a2 = (1, 2)
print(a1)
print(a2)

# 解构列表
mylist = list(range(10))
a, *b, c = mylist
print(a)    # 0
print(b)    # [1, 2, 3, 4, 5, 6, 7, 8]
print(c)    # 9

# 交换元素
a, b = 1, 2
a, b = b, a
print(a)    # 2
print(b)    # 1

# 忽略元素
a, _, _, _, b = (1, 2, 3, 4, 5)
print(a)
print(b)

# py编程规范: 下划线代指想丢弃的变量
e, *_ = 'a!@^%$#%@^%'
print(e)    # a


# zip
a = [1, 2, 3]
b = [4, 5, 6]
zip_list = list(zip(a, b))
print(zip_list) # [(1, 4), (2, 5), (3, 6)]

# unzip (加*是固定搭配)
zip_list = [(1, 4), (2, 5), (3, 6)]
origin = list(zip(*zip_list))
print(origin)   # [(1, 2, 3), (4, 5, 6)]
